// ignore_for_file: avoid_unnecessary_containers

import 'package:flutter/material.dart';

class LoginPage extends StatefulWidget {
  const LoginPage({super.key});

  @override
  State<LoginPage> createState() => _LoginPageState();
}

class _LoginPageState extends State<LoginPage> {
  bool _showPassword = false;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('登录'),
      ),
      body: SafeArea(
          child: Padding(
        padding: const EdgeInsets.all(20.0),
        child: Column(
          children: [
            const TextField(
              decoration: InputDecoration(
                prefix: Icon(Icons.person),
                labelText: '用户名',
                hintText: '请输入用户名',
              ),
            ),
            const SizedBox(
              height: 10,
            ),
            TextField(
              // keyboardType: TextInputType.number, // 数字键盘
              obscureText: !_showPassword,
              decoration: InputDecoration(
                  prefix: const Icon(Icons.lock),
                  labelText: '密码',
                  hintText: '请输入密码',
                  suffix: IconButton(
                    icon: Icon(_showPassword
                        ? Icons.visibility
                        : Icons.visibility_off),
                    onPressed: () {
                      setState(() {
                        _showPassword = !_showPassword;
                      });
                    },
                  )),
            ),
            const SizedBox(
              height: 20,
            ),
            SizedBox(
              height: 50,
              width: double.infinity,
              child: FilledButton(
                onPressed: () {
                  debugPrint('登录');
                },
                child: const Text('登录'),
              ),
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                const Text('还没有账号？'),
                TextButton(
                  onPressed: () {
                    Navigator.pushNamed(context, 'register');
                  },
                  child: const Text('去注册'),
                )
              ],
            )
          ],
        ),
      )),
    );
  }
}
